package com.qfhd.soft.cjzcore.Model;


import com.qfhd.soft.cjzcore.Core.CJJsonUtils;
import com.qfhd.soft.cjzcore.Core.CJLogger;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class Task_image_detail_model {
//"task_info": {
//        "icon": "https://img.icons8.com/ios-filled/2x/ok-message.png",
//                "task_type": 1,
//                "reward": 300,
//                "total_num": 100,
//                "cost_num": 0,
//                "expire_time": 3600,
//                "condition_notes": "1.打开应用宝搜索“钱叮叮”\r\n2.下载并打开\r\n3.“我的”->“手机号绑定”",
//                "id": 1
//    },

    public int id;

//    @SerializedName("icon")
    public String iconUrl;

//    @SerializedName("task_title")
    public String title;

    public int task_type;//1.注册任务 2.投票 3.转发 4.分享

    //    public String subTitle;
//    @SerializedName("reward")
    public float money;//单位分

//    @SerializedName("cost_num")
    public int doneCount;

//    @SerializedName("total_num")
    public int totalCount;

    //    public int time;
    public int status;//0.任务可接 1.提交结果审核中 2.审核通过 3.审核失败（可接）

//    @SerializedName("condition_notes")
    public String taskTip;

    public List<Task_image_detial_step_model> steps;
    public List<Task_image_submit_model> submits;

    public String getStatus() {
        switch (status) {
            case 0: {
                return "提交";
            }
            case 1: {
                return "审核中";
            }
            case 2: {
                return "已到账";
            }
            case 3: {
                return "提交(审核失败)";
            }
            default: {
                return "无";
            }
        }
    }

    public boolean getEnableStatus(){
        switch (status) {
            case 0: {
                return true;
            }
            case 1: {
                return false;
            }
            case 2: {
                return false;
            }
            case 3: {
                return true;
            }
            default: {
                return true;
            }
        }
    }

    public String getTaskTip() {
        return taskTip;
    }

    public static Task_image_detail_model create() {
        Task_image_detail_model model = new Task_image_detail_model();
        model.iconUrl = "https://img.icons8.com/ios-filled/2x/ok-message.png";
        model.title = "钱叮叮";
        model.money = 300f;
        model.doneCount = 0;
        model.totalCount = 100;
        model.status = 1;
        model.task_type = 1;
        model.taskTip = "\"1.打开应用宝搜索“钱叮叮”\n2.下载并打开\n3.“我的”->“手机号绑定”\"";

        model.steps = new ArrayList<>();
        Task_image_detial_step_model tmp = Task_image_detial_step_model.create(1,1,"下载","https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1585914797033&di=812fccc58a88198e3c83084cbee6e468&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F78%2F52%2F01200000123847134434529793168.jpg");
        model.steps.add(tmp);
        Task_image_detial_step_model tmp1 = Task_image_detial_step_model.create(2,2,"安装",null);
        model.steps.add(tmp1);
        Task_image_detial_step_model tmp2 = Task_image_detial_step_model.create(3,3,"激活",null);
        model.steps.add(tmp2);

        model.submits = new ArrayList<>();
        Task_image_submit_model item = Task_image_submit_model.create(1,1,1,"身份证号码","请输入身份证号码");
        Task_image_submit_model item1 = Task_image_submit_model.create(2,2,2,"上传任务id截图","请上传任务");
        model.submits.add(item);
        model.submits.add(item1);

        return model;
    }

    public static Task_image_detail_model getModelByJSONObject(JSONObject object){
        JSONObject info = CJJsonUtils.getJSONObjectFromKey_string(object,"task_info");
        Task_image_detail_model model = new Task_image_detail_model();
        model.id = CJJsonUtils.getValueFromKey_int(info,"id");
        model.iconUrl = CJJsonUtils.getValueFromKey_string(info,"icon");
        model.title = CJJsonUtils.getValueFromKey_string(info,"task_title");
        model.money = CJJsonUtils.getValueFromKey_float(info,"reward");
        model.doneCount = CJJsonUtils.getValueFromKey_int(info,"cost_num");
        model.totalCount = CJJsonUtils.getValueFromKey_int(info,"total_num");
        model.status = CJJsonUtils.getValueFromKey_int(info,"status");
        model.task_type = CJJsonUtils.getValueFromKey_int(info,"task_type");
        model.taskTip = CJJsonUtils.getValueFromKey_string(info,"condition_notes");

        model.steps = Task_image_detial_step_model.getListByJSONArray(CJJsonUtils.getJSONArrayFromKey(object,"steps"));
        model.submits = Task_image_submit_model.getListByJSONArray(CJJsonUtils.getJSONArrayFromKey(object,"requires"));
        return model;
    }
}
